//using System.Collections.Generic;

//public class ChainHistoryItem
//{
//    public string key;
//    public string value;
//}

//public class PromptImprover
//{
//    private ChatChainConfig chatChainConfig;
//    /// <summary>
//    /// string: chatHistory, string: conclusion
//    /// </summary>
//    public List<ChainHistoryItem> chainHistory = new();

//    private ChainHistoryItem _chainHistoryItem = new ChainHistoryItem();

//    public int executionAmount = 10;
//    public int executionCounter = 0;


//    [Inject] private ChatAgentService _chatAgentService;
//    [Inject] private HumanComService _humanComService;
//    [Inject] private ChatChainService _chatChainService;
//    [Inject] private ChatChainModel _chainModel;

//    private int _humanRequestedCounter = 0;

//    private ChatAgentEnum targetEvaluateAgent;

//    private AgentSetupInfo agentSetupInfo;
//    private ChatAgentBase _promptImproverAgent;


//    private string expectedOutput;

//    #region Sub

//    protected void Awake()
//    {
//        _promptImproverAgent = _chatAgentService.CreateAgent(agentSetupInfo);
//        _chatAgentService.OnAssistMsgAddedToAgent += OnAssistantMsg;
//        _humanComService.OnChatRequest += OnChatRequestHandler;
//        _chatChainService.chatChainFinished += ChatChainFinishedHandler;
//    }

//    protected void OnDestroy()
//    {
//        _chatAgentService.OnAssistMsgAddedToAgent -= OnAssistantMsg;
//        _humanComService.OnChatRequest -= OnChatRequestHandler;
//        _chatChainService.chatChainFinished -= ChatChainFinishedHandler;
//    }

//    #endregion

//    private void ChatChainFinishedHandler()
//    {
//        var fullLog = _chatAgentService.GetFullLog(targetEvaluateAgent);
//        //TODO: two ways to get response, one is from the chatAgentService, one is from the ComBaseClass
//        _chatAgentService.AddUserMsg(_promptImproverAgent.ID, $"The expected output of \'{targetEvaluateAgent.ToString()}\' is \'{expectedOutput}\'. \n" +
//                                                              $"Now Review the following prompt history: \n" +
//                                                              $"{fullLog}");
//        _promptImproverAgent.TryAuthorize();

//        _chainHistoryItem = new ChainHistoryItem
//        {
//            key = fullLog
//        };
//    }

//    private void OnAssistantMsg(ChatAgentBase forAgent, string msg)
//    {
//        if (forAgent.agentEnum != ChatAgentEnum.PromptImprover)
//        {
//            return;
//        }

//        Debug.Log("Got message from prompt improver");

//        _chainHistoryItem.value = msg;
//        chainHistory.Add(_chainHistoryItem);

//        forAgent.ClearMemo();

//        executionCounter += 1;
//        if (executionCounter > executionAmount)
//        {
//            return;
//        }

//        //Reset chain
//        _chatChainService.InitializeChatChain(chatChainConfig);

//    }

//    private void OnChatRequestHandler(string msg)
//    {
//        _humanRequestedCounter += 1;

//        switch (_humanRequestedCounter)
//        {
//            case 1:
//                _humanComService.HumanInputFile();
//                break;
//            default:
//                _humanComService.HumanInput("You decide everything. Don't ask me");
//                break;
//        }
//    }

//    [Button]
//    private string CopyAllChatChainHistory()
//    {
//        var result = "";
//        for (var i = 0; i < chainHistory.Count; i++)
//        {
//            result += $"## {i + 1}: \n";
//            var chainHistoryItem = chainHistory[i];
//            result += chainHistoryItem.key + "\n\n\n ~~~~~~~~~~~~~~~~~ \n\n\n";
//            result += chainHistoryItem.value + "\n\n\n ============= \n\n\n";
//        }

//        return result;
//    }
//}
